import { memo } from 'react'
import { Typography, Checkbox, Space } from 'antd'
import { QuestionCheckboxDefaultProps } from './interface'

const { Paragraph } = Typography

const QuestionRadio = memo(props => {
  const { title, isVertical, list = [] } = { ...QuestionCheckboxDefaultProps, ...props }

  return (
    <div>
      <Paragraph strong>{title}</Paragraph>
      <Space direction={isVertical ? 'vertical' : 'horizontal'}>
        {list.map(opt => (
          <Checkbox key={opt.value} value={opt.value} checked={opt.checked}>
            {opt.text}
          </Checkbox>
        ))}
      </Space>
    </div>
  )
})

export default QuestionRadio
